package org.jeecg.modules.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.mapper.SysRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 平台其他租户角色表 前端控制器
 * </p>
 *
 * @Author scott
 * @since 2018-12-19
 */
@RestController
@RequestMapping("/sys/otherTenant/role")
@Slf4j
public class SysOtherTenantRoleController {
	@Autowired
	private SysRoleMapper sysRoleMapper;
	
	/**
	  * 获取其他租户的角色编码为admin的角色 分页列表查询
	 * @param role
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public Result<IPage<Map<String, Object>>> queryPageList(SysRole role,
									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
									  HttpServletRequest req) {
		Result<IPage<Map<String, Object>>> result = new Result<>();
		Page page = new Page(pageNo, pageSize);
		IPage<Map<String, Object>> pageList = sysRoleMapper.otherTenantRolePage(page, CommonConstant.ROLE_CODE_ADMIN,req.getParameter("name"));
		result.setSuccess(true);
		result.setResult(pageList);
		return result;
	}

	
}
